Read(Byte[],Int32,Int32) Method
Reads a sequence of bytes from the current
OracleLob stream and advances the position within the stream by the number of bytes read.
'Declaration
Public Overloads Overrides Function Read( _
ByVal () As Byte, _
ByVal As Integer, _
ByVal As Integer _
) As Integer
Parameters
- buffer
- The byte array buffer to be populated.
- offset
- The zero-based byte offset in the buffer.
- count
- The amount of bytes to read.
Return Value
The total number of bytes read into the buffer.
In the example below a
OracleLob is created with 10 bytes in it. Then
Position is changed using
Seek method. An attempt to read 10 bytes is made afterwards, however, only 5 bytes remain till the end of the stream, so TargetArray is populated with 5 bytes only.
public void ReadFromMyLob()
{
byte[] myByteArray = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
byte[] TargetArray = new Byte[15];
OracleLob myLob = new OracleLob(OracleDbType.Blob);
myLob.Write(myByteArray, 0, 10);
myLob.Seek(5, SeekOrigin.Begin);
Console.WriteLine(myLob.Read(TargetArray, 0, 10) + " bytes are read");
}
Public Sub ReadFromMyLob()
Dim myByteArray As Byte() = New Byte() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
Dim TargetArray As Byte() = New Byte(15 - 1) {}
Dim myLob As New OracleLob(3)
myLob.Write(myByteArray, 0, 10)
myLob.Seek(5, SeekOrigin.Begin)
Console.WriteLine((myLob.Read(TargetArray, 0, 10) & " bytes are read"))
End Sub